package com.aiyige.model.request;

import com.aiyige.base.api.ApiManager;
import com.aiyige.page.publish.util.PublishUtil;

import okhttp3.ResponseBody;
import retrofit2.Call;

/**
 * Created by zhuyakun on 2017/11/22.
 */

public class QueryOwnerGoodsByConditionRequest {
    private int type;
    private Integer status;
    private String keyWord;
    private int pageNum;
    private int pageSize;

    private QueryOwnerGoodsByConditionRequest(Builder builder) {
        setType(builder.type);
        setStatus(builder.status);
        setKeyWord(builder.keyWord);
        setPageNum(builder.pageNum);
        setPageSize(builder.pageSize);
    }

    public static Builder newBuilder() {
        return new Builder();
    }

    public int getType() {
        return type;
    }

    public void setType(int type) {
        this.type = type;
    }

    public Integer getStatus() {
        return status;
    }

    public void setStatus(Integer status) {
        this.status = status;
    }

    public String getKeyWord() {
        return keyWord;
    }

    public void setKeyWord(String keyWord) {
        this.keyWord = keyWord;
    }

    public int getPageNum() {
        return pageNum;
    }

    public void setPageNum(int pageNum) {
        this.pageNum = pageNum;
    }

    public int getPageSize() {
        return pageSize;
    }

    public void setPageSize(int pageSize) {
        this.pageSize = pageSize;
    }

    public static final class Builder {
        private int type;
        private Integer status = null;
        private String keyWord = null;
        private int pageNum;
        private int pageSize = 15;

        private Builder() {
        }

        public Builder type(int type) {
            this.type = type;
            return this;
        }

        public Builder status(Integer status) {
            if (status != null) {
                switch (status) {
                    case PublishUtil.PROGRESS_STATUS_IN_REVIEW:
                        this.status = 0;
                        break;
                    case PublishUtil.PROGRESS_STATUS_NOT_PUBLISHED:
                        this.status = 5;
                        break;
                    case PublishUtil.PROGRESS_STATUS_PUBLISHED:
                        this.status = 3;
                        break;
                    case PublishUtil.PROGRESS_STATUS_REJECT:
                        this.status = 2;
                        break;
                }
            } else {
                this.status = null;
            }
            return this;
        }

        public Builder keyWord(String keyWord) {
            this.keyWord = keyWord;
            return this;
        }

        public Builder pageNum(int pageNum) {
            this.pageNum = pageNum;
            return this;
        }

        public Builder pageSize(int pageSize) {
            this.pageSize = pageSize;
            return this;
        }

        public Call<ResponseBody> build() {
            return ApiManager.getService().queryOwnerGoodsByCondition(new QueryOwnerGoodsByConditionRequest(this));
        }
    }
}
